import { reactive,computed } from 'vue'
import { defineStore } from 'pinia'
import { iface_agreement,iface_ssq, iface_zd } from '@/types/global';

export const useAgreementStore = defineStore('agreement', () => {
	const agreement = reactive({
		xybh:'',
		type: '',
		jf: '',
		yf: '',
		sign:'',
		startDate: new Date(),
		endDate: new Date(),
		areas: [],
		zds: [],
		pp:[],
		areaTasks:[],
		zdTasks:[],
		activities:[],
		companies:[],
		products:[]
	} as iface_agreement)
	// const getAgreementInfo = computed(() => {
	// 	agreement.xybh = agreement.xybh.toLocaleUpperCase();
	// 	return agreement;
	// })
	function updateAgreementProperty(key : keyof iface_agreement, value : any) { agreement[key] = value; }
	function addArea (ssq:iface_ssq){
		agreement.areas.push(ssq);
	}
	function addZd (zd:iface_zd){
		agreement.zds.push(zd);
	}
	return { agreement,updateAgreementProperty,addArea,addZd}
})